<?php
    use User\Model\LpicModel;
?>
<div class="row">
    <div class="col-lg-12">
        <section class="panel">
            <header class="panel-heading">
                专题详情
            </header>
            <div class="panel-body">
                <form class="form-horizontal" method="post"
                      action="/User/Lpic/itemUpdate">
                    <input type="hidden" value="<?php echo I('get.liveId', '', '');?>" name="live_id" id="live_id">
                    <input type="hidden" value="<?php $val = (!empty($item)) ?
                            $item['item_id'] : ''; echo $val;?>" name="itemId" id="itemId">
                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label need">专题名称:</label>

                        <div class="col-lg-4">
                            <input type="text" class="form-control" name="name" value="<?php $val=(!empty($item)) ?
                            $item['name'] : ''; echo $val;?>" id="name">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label need">专题描述:</label>

                        <div class="col-lg-4">
                            <textarea id="describe" class="form-control" style="width:300px;height:100px;" name="describe"><?php echo $item['describe']?></textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label">专题模板:</label>

                        <div class="col-sm-10">
                            <div >
                                <input type="radio" name="type" value="1" <?php if(empty($item) || ($item['type'] == 1)){
                                echo 'checked';
                                }?>>类型A
                                <input type="radio" name="type" value="2" <?php if(!empty($item) && ($item['type'] == 2)){
                                echo 'checked';
                                }?>>类型B
                            </div>
                            <img src="/Public/images/lpic/item_type.jpg" style="width: 700px;height: 500px;">
                        </div>
                    </div>


                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-10">
                            <button class="btn btn-primary" type="submit" id="submit">提交</button>
                            <button class="btn btn-default" type="button" onclick="history.back(-1);">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
</div>
<script>
    $("#submit").click(function () {
        var data = $("form").serialize();
        var url = $("form").attr("action");
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: url,
            async:false,
            success: function (res) {
                if (res.code == 1) {
                    alert("提交成功");
                    window.location = '/User/Lpic/item?id=' + res.live_id;
                } else {
                    alert(res.msg);
                }
            }
        });
        return false;
    });
</script>